<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml" >
        <ui:define name="title">
            <h:outputText value="Home"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" id="form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>

                <p:panel>
                    <p:panel styleClass="image">
                        <p:growl id="messages" showDetail="true"/> 
                        <f:facet name="header">
                            <p:outputLabel value="Digite a Descrição do Produto" />
                        </f:facet>
                        <p:inputText  label="Digite a Descrição do Produto" value="#{productController.descricao}" title="Descrição" size="145"   >
                            <p:ajax event="keyup" update="tabela" listener="#{productController.pesquisa()}" />
                        </p:inputText>

                    </p:panel>

                    <p:panel>
                        <p:dataTable value="#{productController.items}" var="item" id="tabela" style="border:solid 1px" >
                            
                             
                            
                            <f:facet name="header">
                                <h:outputText value="Pesquisa"/>
                            </f:facet>
                             <f:facet name="footer">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListProductTitle_ID}"/>
                                </f:facet>
                                <h:outputText value="#{item.ID}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListProductTitle_description}"/>
                                </f:facet>
                                <h:outputText value="#{item.description}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListProductTitle_price}"/>
                                </f:facet>
                                <h:outputText value="#{item.price}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListProductTitle_supply}"/>
                                </f:facet>
                                <h:outputText value="#{item.supply.name}"/>
                            </p:column>
                            <p:column rendered="#{personController.logado}">
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton id="add" action="#{orderesController.addCarrinho(item.ID)}" value="Add"/>
                                <h:outputText value=" "/>
                                <p:commandButton action="#{productController.prepareViewPES(item.ID)}" value="#{bundle.ListProductViewLink}" rendered="#{personController.logado}"/>
                                
                            </p:column>


                        </p:dataTable>
                    </p:panel>
                    <br />

                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
